#ifdef _WIN32
#ifndef STRAY_GRAPHICS_VERTEX_BUFFER_DX9_H
#define STRAY_GRAPHICS_VERTEX_BUFFER_DX9_H

#include <d3d9.h>

#include "../../SmartPtr/IntrusivePtr.h"
#include "../VertexBuffer.h"
#include "LostResource\LostResource.h"

namespace Stray {
namespace Core {
namespace Graphics {
namespace DirectX9 {

class VertexBufferDX9 : public Stray::Core::Graphics::VertexBuffer, public LostResource
{
	friend class DeviceDX9;
	friend class ContextDX9;
private:
	VertexBufferDX9(IDirect3DVertexBuffer9 *pVertexBuffer, DeviceDX9 *pDevice);
public:
	~VertexBufferDX9();

	void releaseResource();
	void recoverResource();

	size_t getSize() const;
	void* lock(Stray::Core::Graphics::LockFlag flag = Stray::Core::Graphics::LF_READWRITE);
	void unlock();
	void writeData(void* pData, Stray::Uint32 size);
	void readData(void* pData, Stray::Uint32 *pSize);

	void* getNativeHandle() const;
private:
	IDirect3DVertexBuffer9 *pVertexBuffer_;
	D3DVERTEXBUFFER_DESC desc_;
};

typedef Stray::IntrusivePtr<VertexBufferDX9>::type VertexBufferDX9Ptr;

}
}
}
}

#endif
#endif